package webxml;
import java.io.*;
import java.util.*;  
public class logfile {
	public static String GetDate()
	{
		java.util.Calendar ca = Calendar.getInstance();
		java.util.Date now = ca.getTime();
		String result = "";
		result +=  cppprintf( 1900+ now.getYear());
		result +=  cppprintf(now.getMonth()+1);
		result +=  cppprintf(now.getDate());
		//result +=  cppprintf(now.getHours());	
		//result +=  cppprintf(now.getMinutes());	
		//result +=  cppprintf(now.getSeconds());
		return result;
	}
	
	public static String GetDatetime()
	{
		java.util.Calendar ca = Calendar.getInstance();
		java.util.Date now = ca.getTime();
		String result = "";
		result +=  cppprintf( 1900+ now.getYear());
		result +=  cppprintf(now.getMonth()+1);
		result +=  cppprintf(now.getDate());
		result += " " ;
		result +=  cppprintf(now.getHours());
		result += " :" ;
		result +=  cppprintf(now.getMinutes());	
		result += " :" ;
		result +=  cppprintf(now.getSeconds());
		return result;
	}
	
	public static String cppprintf( int x)
	{
		String result ="";
		
		if (x <=9)
		{
		   result += "0";
		}
		result += x;

		return result;

	}
	public static void writelog(String filename, String outxml )
	{
	
	try{
		//return;
		filename = GetDate()+ filename;
		File file = new File( filename );	
		FileWriter filewriter = new FileWriter(file, true);
		filewriter.write(GetDatetime());
		filewriter.write(" ");		
		filewriter.write(outxml);
		filewriter.write("\r\n\r\n");
		filewriter.close();
	} catch(Exception e)
	{
		
		
	}
	}

}
